drop database if exists ripple_user;
create database ripple_user default character set utf8mb4 collate utf8mb4_general_ci;

SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for ripple_user_api_config
-- ----------------------------
DROP TABLE IF EXISTS `ripple_user_api_config`;
CREATE TABLE `ripple_user_api_config` (
  `id` bigint NOT NULL COMMENT '主键',
  `name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '属性名称',
  `value` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '属性值',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `create_by` bigint NOT NULL COMMENT '创建人',
  `create_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人名称',
  `update_time` datetime NOT NULL COMMENT '修改时间',
  `update_by` bigint NOT NULL COMMENT '修改人',
  `update_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人名称',
  `status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态（目前无意义）',
  `is_deleted` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否删除（0否、null是）',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='api配置表';

-- ----------------------------
-- Records of ripple_user_api_config
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for ripple_user_api_ip
-- ----------------------------
DROP TABLE IF EXISTS `ripple_user_api_ip`;
CREATE TABLE `ripple_user_api_ip` (
  `id` bigint NOT NULL COMMENT '主键',
  `api_key_id` bigint NOT NULL COMMENT 'apiKey的Id',
  `address` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT 'ip地址',
  `lock_count` int NOT NULL COMMENT '总封禁次数',
  `manual_unlock_count` int NOT NULL COMMENT '人工解封次数',
  `current_lock_count` int NOT NULL COMMENT '当前周期封禁次数',
  `last_lock_time` datetime DEFAULT NULL COMMENT '最近封禁时间',
  `last_lock_duration` int DEFAULT NULL COMMENT '最近封禁时长（min）',
  `lock_id` bigint DEFAULT NULL COMMENT '最近导致封禁的封禁id（与ripple_user_api_ip_lock_detail.id对应）',
  `unlock_time` datetime DEFAULT NULL COMMENT '解封时间',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `create_by` bigint DEFAULT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL COMMENT '修改时间',
  `update_by` bigint DEFAULT NULL COMMENT '修改人',
  `status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态（0正常、1封禁、2永封）',
  `is_deleted` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否删除（0否、null是）',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户apiKey ip';

-- ----------------------------
-- Records of ripple_user_api_ip
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for ripple_user_api_ip_lock_detail
-- ----------------------------
DROP TABLE IF EXISTS `ripple_user_api_ip_lock_detail`;
CREATE TABLE `ripple_user_api_ip_lock_detail` (
  `id` bigint NOT NULL COMMENT '主键',
  `ip_id` bigint NOT NULL COMMENT 'ip的id',
  `type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型（0封禁记录、1解封记录）',
  `operation_type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '操作类型（0系统、1人工）',
  `current_lock_count` int DEFAULT NULL COMMENT '当前封禁次数',
  `lock_duration` int DEFAULT NULL COMMENT '封禁时长（min）',
  `lock_reason` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '封禁原因',
  `lock_id` bigint DEFAULT NULL COMMENT '解封时记录导致封禁的封禁id',
  `unlock_reason` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '解封原因',
  `create_time` datetime NOT NULL COMMENT '创建时间（封禁/解封时间）',
  `create_by` bigint DEFAULT NULL COMMENT '创建人',
  `create_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人名称',
  `update_time` datetime NOT NULL COMMENT '修改时间（目前无意义）',
  `update_by` bigint DEFAULT NULL COMMENT '修改人（目前无意义）',
  `status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态（无意义）',
  `is_deleted` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否删除（0否、null是）',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户apiKey ip封禁/解封记录';

-- ----------------------------
-- Records of ripple_user_api_ip_lock_detail
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for ripple_user_api_key
-- ----------------------------
DROP TABLE IF EXISTS `ripple_user_api_key`;
CREATE TABLE `ripple_user_api_key` (
  `id` bigint NOT NULL COMMENT '主键',
  `user_id` bigint NOT NULL COMMENT '用户id',
  `name` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '名称',
  `access_key` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '访问密钥',
  `secret_key` char(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '保密密钥',
  `permission` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '权限，以空格作为间隔',
  `has_ip_limit` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '是否限制ip（0否、1是）',
  `ip_num` int NOT NULL COMMENT 'ip数量',
  `lock_id` bigint DEFAULT NULL COMMENT '最近导致封禁的封禁id（与ripple_user_api_key_lock_detail.id对应）',
  `lock_count` int NOT NULL COMMENT '封禁次数',
  `unlock_count` int NOT NULL COMMENT '解封次数',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `create_by` bigint NOT NULL COMMENT '创建人',
  `update_time` datetime NOT NULL COMMENT '创建时间',
  `update_by` bigint NOT NULL COMMENT '修改人',
  `status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态（0正常、1封禁）',
  `is_deleted` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否删除（0否、null是）',
  PRIMARY KEY (`id`),
  UNIQUE KEY `access_key` (`access_key`),
  UNIQUE KEY `secret_key` (`secret_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户apiKey';

-- ----------------------------
-- Records of ripple_user_api_key
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for ripple_user_api_key_lock_detail
-- ----------------------------
DROP TABLE IF EXISTS `ripple_user_api_key_lock_detail`;
CREATE TABLE `ripple_user_api_key_lock_detail` (
  `id` bigint NOT NULL COMMENT '主键',
  `api_key_id` bigint NOT NULL COMMENT 'apiKey的id',
  `type` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '类型（0封禁记录、1解封记录）',
  `lock_id` bigint DEFAULT NULL COMMENT '解封时记录导致封禁的封禁id',
  `remark` varchar(200) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '备注',
  `create_time` datetime NOT NULL COMMENT '创建时间（封禁/解封时间）',
  `create_by` bigint DEFAULT NULL COMMENT '创建人',
  `create_name` varchar(20) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人名称',
  `update_time` datetime NOT NULL COMMENT '修改时间（目前无意义）',
  `update_by` bigint DEFAULT NULL COMMENT '修改人（目前无意义）',
  `status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态（无意义）',
  `is_deleted` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否删除（0否、null是）',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='用户apiKey封禁/解封记录';

-- ----------------------------
-- Records of ripple_user_api_key_lock_detail
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for ripple_user_api_lock_duration
-- ----------------------------
DROP TABLE IF EXISTS `ripple_user_api_lock_duration`;
CREATE TABLE `ripple_user_api_lock_duration` (
  `id` bigint NOT NULL COMMENT '主键',
  `lock_num` int NOT NULL COMMENT '封禁次数',
  `duration` int NOT NULL COMMENT '封禁时长',
  `create_time` datetime NOT NULL COMMENT '创建时间',
  `create_by` bigint NOT NULL COMMENT '创建人',
  `create_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '创建人名称',
  `update_time` datetime NOT NULL COMMENT '修改时间',
  `update_by` bigint NOT NULL COMMENT '修改人',
  `update_name` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '修改人名称',
  `status` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '状态（目前无意义）',
  `is_deleted` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '是否删除（0否、null是）',
  PRIMARY KEY (`id`),
  UNIQUE KEY `lock_num` (`lock_num`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='Api封禁时长配置表';

-- ----------------------------
-- Records of ripple_user_api_lock_duration
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for undo_log
-- ----------------------------
DROP TABLE IF EXISTS `undo_log`;
CREATE TABLE `undo_log` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `branch_id` bigint NOT NULL,
  `xid` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `context` varchar(128) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL,
  `rollback_info` longblob NOT NULL,
  `log_status` int NOT NULL,
  `log_created` datetime NOT NULL,
  `log_modified` datetime NOT NULL,
  `ext` varchar(100) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL,
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `ux_undo_log` (`xid`,`branch_id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=381038 DEFAULT CHARSET=utf8mb3 ROW_FORMAT=DYNAMIC;

-- ----------------------------
-- Records of undo_log
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for user
-- ----------------------------
DROP TABLE IF EXISTS `user`;
CREATE TABLE `user` (
  `id` bigint unsigned NOT NULL AUTO_INCREMENT COMMENT '系统id',
  `uid` bigint NOT NULL COMMENT '用户id',
  `email` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '邮箱',
  `chain` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL COMMENT '授权公链(字典项public_chain)',
  `address` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci NOT NULL COMMENT '授权地址',
  `money_password` varchar(64) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '资金密码',
  `invite_code` varchar(32) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '客户邀请码',
  `inviter_id` bigint DEFAULT NULL COMMENT '邀请人uid',
  `is_broker` smallint NOT NULL DEFAULT '0' COMMENT '是否经纪人 0 否 1 是',
  `is_confrim_risk` smallint NOT NULL DEFAULT '0' COMMENT '是否确认风险告知 0否 1是',
  `status` smallint NOT NULL DEFAULT '0' COMMENT '账户状态（0=正常，1=禁用 ）',
  `language_code` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '用户选择语言编号',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '修改时间',
  `last_time` datetime DEFAULT NULL COMMENT '最后登录时间',
  `last_ip` varchar(32) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL COMMENT '最后登录IP',
  `del_flag` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT '0' COMMENT '逻辑删除标志',
  `platform_commission_percentage` int NOT NULL DEFAULT '0' COMMENT '平台反佣比例',
  `agent_commission_percentage` int NOT NULL DEFAULT '0' COMMENT '经纪人反佣比例',
  `parent_agent_id` bigint DEFAULT NULL COMMENT '用户所属最终父级经纪人',
  `api_key_num` int NOT NULL DEFAULT '0' COMMENT 'apiKey数量',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `uid` (`uid`)
) ENGINE=InnoDB AUTO_INCREMENT=1646068013106319361 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci COMMENT='平台客户';

-- ----------------------------
-- Records of user
-- ----------------------------
BEGIN;
INSERT INTO `user` VALUES (1646068013106319360, 1646068013085347840, '1036532868@qq.com', '1', '0xfF934Aeac80a33f10Fc65A0a863faE832795AE7E', '25d55ad283aa400af464c76d713c07ad', 'HMVTDTlBHSNH', NULL, 0, 0, 0, 'zh_CN', '2023-04-12 16:29:31', '2023-04-12 16:29:31', NULL, NULL, '0', 0, 0, NULL, 0);
COMMIT;

-- ----------------------------
-- Table structure for user_logs
-- ----------------------------
DROP TABLE IF EXISTS `user_logs`;
CREATE TABLE `user_logs` (
  `id` bigint NOT NULL AUTO_INCREMENT,
  `uid` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL COMMENT '用户id',
  `log_type` char(1) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT '0' COMMENT '日志类型',
  `content` varchar(255) CHARACTER SET utf8mb3 COLLATE utf8mb3_general_ci DEFAULT NULL COMMENT '内容',
  `ip` varchar(255) CHARACTER SET latin1 COLLATE latin1_swedish_ci DEFAULT NULL COMMENT 'IP',
  `create_date` datetime DEFAULT NULL COMMENT '时间',
  `user_agent` varchar(1000) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `request_uri` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL COMMENT '请求路径',
  `method` varchar(10) CHARACTER SET utf8mb4 COLLATE utf8mb4_0900_ai_ci DEFAULT NULL,
  `params` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
  `time` bigint NOT NULL COMMENT '执行时间',
  `exception` text CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci,
  PRIMARY KEY (`id`,`time`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=latin1 COMMENT='平台客户日志';

-- ----------------------------
-- Records of user_logs
-- ----------------------------
BEGIN;
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
